package cn.ow.converter;

import cn.hutool.core.util.ObjectUtil;
import cn.ow.bean.StockExcelEntity;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jiaju Zhuang
 */
public class ConverterDataListener extends AnalysisEventListener<StockExcelEntity> {
    private static final Logger LOGGER = LoggerFactory.getLogger(ConverterDataListener.class);
    public final List<StockExcelEntity> list = new ArrayList<>();

    @Override
    public void invoke(StockExcelEntity data, AnalysisContext context) {
        if(ObjectUtil.isNotEmpty(data)){
            list.add(data);
        }
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
//        Assertions.assertEquals(list.size(), 1);
//        ConverterReadData2 data = list.get(0);
//
//        LOGGER.debug("First row:{}", JSON.toJSONString(list.get(0)));
    }
}
